package gu1;

import java.util.*;
import java.util.Map.Entry;
public class main2 {
public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		Map <String,TreeSet<Integer>> dict = new TreeMap<String,TreeSet<Integer>>();
		TreeSet <Integer> value = new TreeSet<Integer>();
		int a = 0;
		while(sc.hasNextLine())
		{
			//System.out.println(sc.nextLine());
			a++;
			value.add(a);
			String b[]=sc.nextLine().split(" ");
			for (int i = 0; i < b.length; i++) {
				if(b.equals("!!!!!"))
					break;
				System.out.println(b[i]);
				dict.put(b[i], value);
			}
			
		}
	for(Entry<String,TreeSet<Integer>> e: dict.entrySet()){
		System.out.println(e);
	}
}
}
